package org.box.metadata.cli.impl;


import org.apache.commons.cli.CommandLine;
import org.box.metadata.cli.CommandLineParser;
import org.box.metadata.cli.annotation.CLIConfiguration;
import org.box.metadata.cli.annotation.Command;
import org.box.metadata.cli.exception.ParseException;
/**
 * Declares command support for {@link CommandLineParser}. E.g.:
 * 
 * <pre>
 * prompt> app.exe create -f infile.txt
 * </pre>
 * 
 * A word 'create' is the command in the given command line and '-f' and
 * 'infile.txt' are specific option and argument for this command.
 * </p>
 * 
 * <p>
 * A type of the marked field is a POJO class, very close to
 * {@link CLIConfiguration} type class since commands may have own options and
 * argument specific for them.
 * </p>
 * <p>
 * The following snippet of {@link CLIConfiguration} shows command declarations
 * example:
 * 
 * <pre>
 * 
 * &#064;CLIConfiguration()
 * public class MyConfiguration {
 * 
 * 	&#064;Command(description = &quot;create command&quot;, name = &quot;create&quot;)
 * 	public MyCreateCommand create;
 * 
 * }
 * </pre>
 * 
 * And <code>MyCreateCommand</code> class would be like this:
 * 
 * <pre>
 * 
 * public class MyCreateCommand {
 * 
 * 	&#064;Option(description = &quot;A simple yes/no option for the 'create' command&quot;, fullName = &quot;force&quot;, shortName = &quot;f&quot;)
 * 	public boolean f;
 * 
 * 	&#064;Argument(index = 1, name = &quot;infile&quot;, required = true)
 * 	public String infile;
 * 
 * }
 * 
 * 
 * </pre>
 * 
 * @see CommandLineParser
 * 
 * @author <a href="mailto:alexander.box@gmail.com">Alexander Korobka</a>
 *
 */
public interface CommandCompatible {
	
	CommandLine parse(boolean incCommonOptions, Class<?> cfgClass, String[] arguments) throws ParseException;

	/**
	 * Finds and returns a command in the given arguments or returns a default 
	 * command, if no commands matched
	 * 
	 * @see DefaultCommand
	 * 
	 * @param cfgClass - a list of commands to a check
	 * @param args - a list of args to a check
	 * 
	 * @return a matched command or default command
	 */
	Command findCommand(Class<?> cfgClass, String[] args);
    
    
}
